package com.ta.oa.sys.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ta.oa.sys.entity.SysUser;
import com.ta.oa.sys.service.SysUserService;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * 用户信息表(SysUser)表控制层
 *
 * @author danxinshang
 * @since 2021-12-16 00:35:30
 */
@RestController
@RequestMapping("/user")
public class SysUserController  {
    /**
     * 服务对象
     */
    @Resource
    private SysUserService sysUserService;

    @RequestMapping("/get")
    @ResponseBody
    public String get(@RequestParam String username){
        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_name",username);
        SysUser user = sysUserService.getOne(queryWrapper);
        if(user!=null){
            System.out.println("user.getName():"+user.getUserName());
        }
        return JSON.toJSONString(user);

    }
    @RequestMapping("/exception")
    @ResponseBody
    public String exception(){
        throw new RuntimeException();
    }
}

